/**
 * jgamebox
 *
 * outlook@China software studio
 * Copyright (c) 2008-2011. All Rights Reserved.
 * http://www.outlook.com
 */

package org.outlook.jgamebox.util;

import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

import org.outlook.jgamebox.role.Spriter;

/**
 * function:
 * @author watson  email: watson.wu@hotmail.com
 * @date 2011-5-29
 */
public class SpritorDecorator {
	

	public static void decorate(Spriter spriter, URL filePath) {
		if(spriter == null || null == filePath) return ;
		final ImageIcon icon = new ImageIcon(getImage(filePath));
		spriter.setImage(new JLabel(icon));
	}
	
	public static JLabel decorate(URL filePath) {
		final ImageIcon icon = new ImageIcon(getImage(filePath));
		return new JLabel(icon);
	}
	
	public static Image getImage(URL filePath) {
		return Toolkit.getDefaultToolkit().getImage(filePath);
	}

}
